//
//  Status.swift
//  JJWeibo
//
//  Created by JJ on 15/9/6.
//  Copyright © 2015年 JJ. All rights reserved.
//

import UIKit

class Status: NSObject {
    
    var created_at:String?
    
    var id:Int=0
    
    var text:String?
    
    var source:String?{
        didSet{
            
            source=source?.href()?.text
        }
    }
    
    var user:User?
    
    var retweeted_status:Status?
    
    var pic_urls:[[String:String]]?
    
    init(dic:[String:AnyObject]){
        super.init()
        
        setValuesForKeysWithDictionary(dic)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key=="user"{
            
            user=User(dic:value as![String:AnyObject])
            
            return
        }
        if key=="retweeted_status"{
            
            retweeted_status=Status(dic: value as![String:AnyObject])
            return 
        }
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description:String{
        
        let keys=["created_at","id","text","source","user","pic_urls","retweeted_status"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
